<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="admin/common/html/head :: head(~{::title},~{::link},~{::style})">

<title th:text=${title}></title>
<!-- 这儿引用单独的css link -->
<!-- Ladda for Bootstrap 3按钮加载进度插件 -->
<link rel="stylesheet" th:href="@{/static/admin/assets/js/button/ladda/ladda.min.css}">
<!-- bootstrap-table表单样式 -->
<link th:href="@{/static/admin/assets/js/bootstrap/css/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>

<style type="text/css">
/**
*这里写单独的css样式
*/
.select-list ul li{
	list-style-type: none;
	float: left;
}
</style>

</head>

<body>




<!--
<!-- 右边内容 -->
<div class="wrap-fluid">
    <div class="container-fluid paper-wrap bevel tlbr">
        <!-- 内容 -->
        <!--标题 通用-->
        <div th:replace="admin/common/html/title :: title(${title},${parenttitle},${isMsg},${msgHTML})">
        </div>
        <!-- 结束标题 通用-->
        <div class="content-wrap">
            <!-- 结束内容 -->
            <div class="row">
                <div class="col-sm-12">
                <!-- 搜索条件 -->

                	 <div class="nest" id="inlineClose">
                            <div class="title-alt">
                                <h6>搜索条件</h6>
                                <div class="titleClose">
                                    <a class="gone" href="#inlineClose">
                                        <span class="entypo-cancel"></span>
                                    </a>
                                </div>
                                <div class="titleToggle">
                                    <a class="nav-toggle-alt" href="#search_div" >
                                        <span class="entypo-down-open"></span>
                                    </a>
                                </div>
                            </div>

                            <div class="body-nest" id="search_div" style="display: none">
                                <div class="form_left">
                                    <form role="form" class="form-inline">
                                        <div class="form-group">
                                            <label for="exampleInputEmail2" class="sr-only">搜索商品名称</label>
                                            <input type="text" name="searchTxt" placeholder="搜索商品名称"class="form-control">
                                        </div>
                                        <button onclick="$.table.search(this)" class="btn btn-success" type="button"><i class="fa fa-search"></i>&nbsp;搜索</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                	<!-- END搜索条件 -->
                    <!-- 空白页开始-->
                    <div class="nest" id="Blank_PageClose">
                        <div class="title-alt">
                            <h6>表单</h6>
                            <div class="titleClose">
                                <a class="gone" href="#Blank_PageClose">
                                    <span class="entypo-cancel"></span>
                                </a>
                            </div>
                            <div class="titleToggle">
                                <a class="nav-toggle-alt" href="#Blank_Page_Content">
                                    <span class="entypo-up-open"></span>
                                </a>
                            </div>
                        </div>

                        <div class="body-nest" id="Blank_Page_Content">
                            <!-- 工具条 -->
                            <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                            	<button onclick="$.operate.add()" type="button" class="btn btn-primary">
                                    <span class="entypo-plus-squared"></span>&nbsp;&nbsp;新增
                                </button>
                               <button onclick="$.operate.batRemove()" type="button" class="btn btn-info">
                                    <span class="entypo-trash"></span>&nbsp;&nbsp;删除
                               </button>

                           </div>
                            <!-- 工具条 end-->
                           <table id="dataTable" class="table-striped footable-res footable metro-blue" data-page-size="6">


                           </table>


                        </div>
                    </div>
                </div>
                <!-- 空白页结束 -->
            </div>
            <!-- 结束内容 -->
            <!-- 页脚 通用-->
            <div th:replace="admin/common/html/footer :: footer">
            </div>
            <!-- 结束页脚通用 -->
        </div>
    </div>
</div>
<!-- 结束右边内容 -->
<!--






<!-- 右侧隐藏滑块内容 -->
<div th:include="admin/common/html/rightHide :: rightHide">

</div>
   <!-- END 右侧隐藏滑块内容-->

<!-- 通用js -->
<div th:include="admin/common/html/js :: onload_js">

</div>
<!-- bootstarp 表格 -->
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/bootstrap-table.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/js/base_list.js}" type="text/javascript"></script>
<!-- 导出 -->
<script th:src="@{/static/admin/assets/js/bootstrap/extensions/export/bootstrap-table-export.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/bootstrap/extensions/export/tableExport.js}" type="text/javascript"></script>

<!-- 弹窗 -->
<script th:src="@{/static/admin/assets/js/layer/layer.js}" type="text/javascript"></script>
<!-- 遮罩层 -->
<script th:src="@{/static/admin/assets/js/blockUI/jquery.blockUI.js}" type="text/javascript"></script>

<script type="text/javascript">
    <!-- jquery-export 表格导出插件 -->

    <!-- 导出 -->
    var dataUrl=window.rootPath+"/TAbbCGoodsController/list";
    var removeUrl=window.rootPath+"/TAbbCGoodsController/remove";
    var createUrl=window.rootPath+"/TAbbCGoodsController/add";
    var updateUrl=window.rootPath+"/TAbbCGoodsController/edit/{id}";
    var exportUrl=window.rootPath+"/TAbbCGoodsController/export";
    var options = {
        dataUrl: dataUrl,
        createUrl: createUrl,
        updateUrl: updateUrl,
        removeUrl:removeUrl,
        exportUrl: exportUrl,
        sortName: "roleSort",
        modalName: "",
        search: false,
        dataColumns: [
            {
                checkbox: true
            },
            {
                field: 'id',
                title: '序号',
                visible: false
            },
            {
                field: 'goodsbianhao',
                title: '商品编号'
            },
            {
                field: 'isdel',
                title: '是否上架',
                formatter: function (value, row, index) {
                    var actions = [];
                    if(value==0){
                        actions.push('已上架');
                    }else if(value==1){
                        actions.push('已下架');
                    }
                    return actions.join('');
                }
            },
            {
                field: 'ishotpush',
                title: '是否是热推商品',
                formatter: function (value, row, index) {
                    var actions = [];
                    if(value==0){
                        actions.push('不是');
                    }else if(value==1){
                        actions.push('是');
                    }
                    return actions.join('');
                }
            },
            {
                field: 'isbaoyou',
                title: '是否包邮',
                formatter: function (value, row, index) {
                    var actions = [];
                    if(value==0){
                        actions.push('不包邮');
                    }else if(value==1){
                        actions.push('包邮');
                    }
                    return actions.join('');
                }

            },
            {
                field: 'area',
                title: '商品分类'
            },
            {
                field: 'goodsname',
                title: '商品名称'
            },
            {
                field: 'yuliu1',
                title: '销售人姓名'
            },
            {
                field: 'yuliu2',
                title: '联系电话'
            },
            {
                field: 'goodslunbo',
                title: '热推商品的轮播图',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-info btn-xs"  href="#" onclick="queryUrl(\'' + value + '\')"><i class="fa fa-edit"></i>查看</a> ');
                    return actions.join('');
                }
            },
            {
                field: 'goodsimages',
                title: '商品图片',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-info btn-xs"  href="#" onclick="queryUrl(\'' + value + '\')"><i class="fa fa-edit"></i>查看</a> ');
                    return actions.join('');
                }
            },
            {
                field: 'goodscontent',
                title: '商品详情（图文）',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-info btn-xs"  href="#" onclick="queryUrl1(\'' + encodeURI(value) + '\')"><i class="fa fa-edit"></i>查看</a> ');
                    return actions.join('');
                }
            },
            {
                field: 'goodsyuanprice',
                    title: '商品原价'
            },
            // {
            //     field: 'goodsyunsongprice',
            //         title: '商品运送价'
            // },
            {
                field: 'goodszitiprice',
                    title: '商品到店支付价'
            },
            {
                field: 'goodsbaoyouprice',
                    title: '包邮价格'
            },
            {
                field: 'creattime',
                    title: '创建时间'
            },

    /*
    参照修改注释
            {
                    field: 'xxstate',
                    title: 'xx状态',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(value==0){
                             actions.push('<span class="label label-primary">关闭</span>');
                        }else if(value==1){
                             actions.push('<span class="label label-danger">开启</span>');
                        }
                          return actions.join('');
                     }
                }
    */
    {
        title: '操作',
            formatter: function (value, row, index) {
        var id = row.id;
        var actions = [];
       /* actions.push('<a class="btn btn-success btn-xs"  href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');*/
        actions.push('<a class="btn btn-success btn-xs"  href="#" onclick="zding(\'' + row.id + '\')"><i class="fa fa-edit"></i>置顶商品</a> ');
        if (row.ishotpush==0) {
            actions.push('<a class="btn btn-success btn-xs"  href="#" onclick="retui(\'' + row.id + '\')"><i class="fa fa-edit"></i>设置为热推</a> ');
        }
        if (row.yuliu3=='1') {
            actions.push('<a class="btn btn-success btn-xs"  href="#" onclick="tuijian(\'' + row.id + '\')"><i class="fa fa-edit"></i>推荐</a> ');
        }
        if (row.yuliu3=='2') {
            actions.push('<a class="btn btn-danger btn-xs"  href="#" onclick="qtuijian(\'' + row.id + '\')"><i class="fa fa-edit"></i>取消推荐</a> ');
        }
        if (row.ishotpush==1) {
            actions.push('<a class="btn btn-danger btn-xs"  href="#" onclick="quxiao(\'' + row.id + '\')"><i class="fa fa-edit"></i>取消热推</a> ');
        }
        if (row.isdel==1) {
            actions.push('<a class="btn btn-success btn-xs"  href="#" onclick="shangjia(\'' + row.id + '\')"><i class="fa fa-edit"></i>上架</a> ');
        }
        if (row.isdel==0){
            actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="xiajia(\'' + row.id + '\')"><i class="fa fa-remove"></i>下架</a>');
        }
        //actions.push('<a class="btn btn-danger btn-xs" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
        return actions.join('');
    }
    }]
    };
    $(function(){
        var oTab=$.table.oTableInit(options);
        oTab.Init();
    })
    function queryUrl1(content){
        var contentstr=decodeURI(content);
        var title="内容详情";
        var width='60%';
        var height='60%';
        layer.open({
            type: 1,//这就是定义窗口类型的属性
            title: title,
            shadeClose: true,
            shade: 0.3,
            offset: "20%",
            shadeClose : false,
            area: [width, height],
            content:contentstr //'传入任意的文本或html' //这里content
            //是一个普通的String 比如："<div>哈哈</div>"
        });
    }
    function queryUrl(images){
        var contentstr='';
        var image=images.split(",");
        for (var i=0;i<image.length;i++){
            contentstr=contentstr+"<img src='"+image[i]+"' width='30%'height='50%'>";
        }
        var title="展示图片";
        var width='60%';
        var height='60%';
        layer.open({
            type: 1,//这就是定义窗口类型的属性
            title: title,
            shadeClose: true,
            shade: 0.3,
            offset: "20%",
            shadeClose : false,
            area: [width, height],
            content:contentstr //'传入任意的文本或html' //这里content
            //是一个普通的String 比如："<div>哈哈</div>"
        });
    }
</script>

<script>
    function zding(id) {
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/TAbbCGoodsController/zding",
            data : {id:id},
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                layer.msg(data.msg, {
                    time: 1000,
                    shade: [0.1, "#8F8F8F"]
                }, function() {
                    location.reload();
                })
            }
        });
    }
    function retui(id) {
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/TAbbCGoodsController/retui",
            data : {id:id},
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                if (data.code==1){
                    layer.msg("请热推商品最多设置3个!", {
                        time: 1000,
                        shade: [0.1, "#8F8F8F"]
                    }, function() {
                        location.reload();
                    })
                }else{
                    layer.msg(data.msg, {
                        time: 1000,
                        shade: [0.1, "#8F8F8F"]
                    }, function() {
                        location.reload();
                    })
                }
            }
        });
    }
    function quxiao(id) {
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/TAbbCGoodsController/quxiao",
            data : {id:id},
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                layer.msg(data.msg, {
                    time: 1000,
                    shade: [0.1, "#8F8F8F"]
                }, function() {
                    location.reload();
                })
            }
        });
    }
    function tuijian(id) {
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/TAbbCGoodsController/tuijian",
            data : {id:id,type:"2",yuliu3:"2"},
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                layer.msg(data.msg, {
                    time: 1000,
                    shade: [0.1, "#8F8F8F"]
                }, function() {
                    location.reload();
                })
            }
        });
    }
    function qtuijian(id) {
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/TAbbCGoodsController/qtuijian",
            data : {id:id,type:"2",yuliu3:"1"},
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                layer.msg(data.msg, {
                    time: 1000,
                    shade: [0.1, "#8F8F8F"]
                }, function() {
                    location.reload();
                })
            }
        });
    }
    function shangjia(id) {
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/TAbbCGoodsController/shangjia",
            data : {id:id},
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                layer.msg(data.msg, {
                    time: 1000,
                    shade: [0.1, "#8F8F8F"]
                }, function() {
                    location.reload();
                })
            }
        });
    }
    function xiajia(id) {
        $.ajax({
            cache : true,
            type : "POST",
            url : rootPath + "/TAbbCGoodsController/xiajia",
            data : {id:id},
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                layer.msg(data.msg, {
                    time: 1000,
                    shade: [0.1, "#8F8F8F"]
                }, function() {
                    location.reload();
                })
            }
        });
    }
</script>
</body>


</html>
